<!DOCTYPE html>
<html lang="en">
<head>
  <title>浩然企业级管理平台</title>
  <meta charset="utf-8">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
  <#include "/common/csslib.html">
</head>
<body>
<div class="main-wrapper">
  <!-- start: MAIN CONTAINER -->
  <div class="main-container inner">
    <!-- start: PAGE -->
    <div class="main-content">
      <div class="container">
        <div class="row h-home-path">
          <div class="col-md-12">
            <ol class="breadcrumb">
              <li><i class="fa fa-home"></i>&nbsp;&nbsp;所在位置</li>
              <li>首页</li>
              <li class="active">编辑脚手架模块文件信息</li>
            </ol>
          </div>
        </div>
        <div class="row h-main-search">
          <form action="javascript:;" method="post">
            <div class="pull-right h-btn-group">
              <button class="btn btn-info" id="return-btn" onclick="returnIndex()"><i class="fa fa-mail-reply">&nbsp;&nbsp;</i>返回
              </button>
              <@permission btnType="save" btnId="saveBtn" btnValue="保存" op="sys:scaffoldModuleFile:save"
              btnMethod="SysScaffoldModuleFileMgr.submitForm()"/>
            </div>
          </form>
        </div>

        <div class="form-horizontal  h-form-warp">
          <div class="h-msg-title h-table-header">
            <strong>脚手架模块文件信息</strong>
          </div>
          <form id="sysScaffoldModuleFileForm" role="form" class="form-horizontal"
                action="/sysScaffoldModuleFile/saveSysScaffoldModuleFile" method="post">
            <input type="hidden" id="operation" name="operation" value="${operation}"/>
            <input type="hidden" class="form-control" value="${sysScaffoldModuleFile.id!}" id="id" name="id">
            <div class="form-group">
              <label class="col-sm-2 control-label">模块id ：</label>
              <div class="col-sm-8">
                <input type="text" class="form-control" value="${sysScaffoldModuleFile.moduleId!}" id="moduleId"
                       name="moduleId"
                       required="required"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">文件编码 ：</label>
              <div class="col-sm-8">
                <input type="text" class="form-control" value="${sysScaffoldModuleFile.fileCode!}" id="fileCode"
                       name="fileCode"
                       required="required"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">文件名称 ：</label>
              <div class="col-sm-8">
                <input type="text" class="form-control" value="${sysScaffoldModuleFile.fileName!}" id="fileName"
                       name="fileName"
                       required="required"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">文件路径 ：</label>
              <div class="col-sm-8">
                <input type="text" class="form-control" value="${sysScaffoldModuleFile.filePath!}" id="filePath"
                       name="filePath"
                       required="required"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">文件类型 ：</label>
              <div class="col-sm-8">
                <input type="text" class="form-control" value="${sysScaffoldModuleFile.fileType!}" id="fileType"
                       name="fileType"
                       required="required"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <input type="hidden" id="fileContent" name="fileContent" />
              <label class="col-sm-2 control-label">文件模板内容 ：</label>
              <div class="col-sm-8">
                <!--style给定宽度可以影响编辑器的最终宽度-->
                <script type="text/plain" id="fileContentEditor" style="width:100%;height:240px;">
                  ${sysScaffoldModuleFile.fileContent!}
              </script>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">文件描述 ：</label>
              <div class="col-sm-8">
                <input type="text" class="form-control" value="${sysScaffoldModuleFile.fileComment!}" id="fileComment"
                       name="fileComment"
                       required="required"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
    <!-- end: PAGE -->
  </div>
  <!-- end: MAIN CONTAINER -->
</div>

<#include "/common/umeditorlib.html">
<!-- 弹窗下拉 -->
<script type="text/javascript">
    function returnIndex() {
        window.location.href = "/sysScaffoldModuleFile/query";
    }

    $(function () {
        // 页面操作类型：add(添加)-edit(编辑)-view(查看)
        var operation = $("#operation").val();
        // 弹出窗体控制
        SysScaffoldModuleFileMgr = {
            // 初始化
            init: function () {
                // 查看的时候不显示保存按钮
                if (operation == "view") {
                    Jmts.setFormReadOnly();
                }
            },
            // init end

            // 提交数据
            submitForm: function () {
                $("#fileContent").val(UM.getEditor('fileContentEditor').getContent());
                Jmts.ajaxSubmit(document.getElementById("sysScaffoldModuleFileForm"), function (result) {
                    if (result.success) {
                        if (operation == 'add') {
                            SysScaffoldModuleFileMgr.returnIndex();
                        } else {
                            Jmts.succTips(result.msg);
                            window.location.reload();
                        }
                    } else {
                        Jmts.warnTips(result.msg);
                    }
                });
                return false;
            },
            // submitForm end
            returnIndex: function () {
                window.location.href = "/sysScaffoldModuleFile/query";
            }
        };
        // 执行初始化
        SysScaffoldModuleFileMgr.init();
    });
</script>

<script type="text/javascript">
    //实例化编辑器
    var um = UM.getEditor('fileContentEditor');
    um.addListener('blur',function(){
        $('#focush2').html('编辑器失去焦点了')
    });
    um.addListener('focus',function(){
        $('#focush2').html('')
    });
    //按钮的操作
    function insertHtml() {
        var value = prompt('插入html代码', '');
        um.execCommand('insertHtml', value)
    }
    function isFocus(){
        alert(um.isFocus())
    }
    function doBlur(){
        um.blur()
    }
    function createEditor() {
        enableBtn();
        um = UM.getEditor('fileContentEditor');
    }
    function getAllHtml() {
        alert(UM.getEditor('fileContentEditor').getAllHtml())
    }
    function getContent() {
        var arr = [];
        arr.push("使用editor.getContent()方法可以获得编辑器的内容");
        arr.push("内容为：");
        arr.push(UM.getEditor('fileContentEditor').getContent());
        alert(arr.join("\n"));
    }
    function getPlainTxt() {
        var arr = [];
        arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
        arr.push("内容为：");
        arr.push(UM.getEditor('fileContentEditor').getPlainTxt());
        alert(arr.join('\n'))
    }
    function setContent(isAppendTo) {
        var arr = [];
        arr.push("使用editor.setContent('欢迎使用umeditor')方法可以设置编辑器的内容");
        UM.getEditor('fileContentEditor').setContent('欢迎使用umeditor', isAppendTo);
        alert(arr.join("\n"));
    }
    function setDisabled() {
        UM.getEditor('fileContentEditor').setDisabled('fullscreen');
        disableBtn("enable");
    }

    function setEnabled() {
        UM.getEditor('fileContentEditor').setEnabled();
        enableBtn();
    }

    function getText() {
        //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
        var range = UM.getEditor('fileContentEditor').selection.getRange();
        range.select();
        var txt = UM.getEditor('fileContentEditor').selection.getText();
        alert(txt)
    }

    function getContentTxt() {
        var arr = [];
        arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
        arr.push("编辑器的纯文本内容为：");
        arr.push(UM.getEditor('fileContentEditor').getContentTxt());
        alert(arr.join("\n"));
    }
    function hasContent() {
        var arr = [];
        arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
        arr.push("判断结果为：");
        arr.push(UM.getEditor('fileContentEditor').hasContents());
        alert(arr.join("\n"));
    }
    function setFocus() {
        UM.getEditor('fileContentEditor').focus();
    }
    function deleteEditor() {
        disableBtn();
        UM.getEditor('fileContentEditor').destroy();
    }
    function disableBtn(str) {
        var div = document.getElementById('btns');
        var btns = domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            if (btn.id == str) {
                domUtils.removeAttributes(btn, ["disabled"]);
            } else {
                btn.setAttribute("disabled", "true");
            }
        }
    }
    function enableBtn() {
        var div = document.getElementById('btns');
        var btns = domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            domUtils.removeAttributes(btn, ["disabled"]);
        }
    }
</script>
</body>
</html>
